#create choropleth map with log transformed overdose deaths per capita
#source code site: https://plotly.com/r/choropleth-maps/
url <- 'https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json'
counties <- rjson::fromJSON(file=url)
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showlakes = TRUE,
lakecolor = toRGB('white')
)
fig <- plot_ly(
type="choropleth",
geojson=counties,
locations=full_data2$fips,
z=full_data2$Log_deaths_per_capita,
text=full_data2$log_county_hover_text,
hoverinfo = "text",
colorscale="Viridis",
colorbar = list(title = "Log Drug Overdose Deaths"),
marker = list(line = list(width = 0)))
fig <- fig %>% layout(
title = "Log Transformed Drug Overdose Deaths \n Per Capita in the US from 2020 to 2024",
geo = g)
fig